#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>

using namespace std;
const int N = 110;

int n;
int q[N];

int slv(int n, string op){
    for(int i = 0; i < op.size(); i ++){
        if(op[i] == 'D'){
            if(n == 9){
                n = 0;
            }else{
                n++;
            }
        }else{
            if(n == 0){
                n = 9;
            }else{
                n --;
            }
        }
    }

    return n;
}

int main(){
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    int T;
    cin >> T;
    string op;
    int k;
    while(T--){
        cin >> n;
        for (int i = 0; i < n; i ++){
            cin >> q[i];
        }

        for (int i = 0; i < n; i ++){
            cin >> k >> op;
            int res = slv(q[i], op);
            q[i] = res;
        }

        for (int i = 0; i < n; i ++){
            cout << q[i] << " ";
        }
        cout << endl;
    }
    return 0;
}